{% extends 'layout.html' %}
{% load static %}
{% load permission %}
{% block content %}
    <div class="container-fluid" style="margin-top: 10px">
        {% if search_group_row_list %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="fa fa-filter" aria-hidden="true"></i> 快速筛选
                    <div class="fold-button pull-right">
                        <span class="open_panel" style="display: none;cursor: pointer;">展开</span>
                        <span class="close_panel" style="cursor: pointer;">收起</span>
                    </div>
                </div>
                <div class="panel-body fold-box">
                    <div class="search-group card card-body">
                        {% for row in search_group_row_list %}
                            <div class="row">
                                {% for obj in row %}
                                    {{ obj|safe }}
                                {% endfor %}
                            </div>
                        {% endfor %}
                    </div>
                </div>
            </div>
        {% endif %}
        <div style="margin-bottom: 10px;" class="right">
            <form class="form-inline" method="get">
                <div class="form-group">
                    <input name="keyword" type="text" class="form-control" placeholder="请输入关键字" value="{{ keyword }}">
                </div>
                <button type="submit" class="btn btn-primary">
                    <span class="glyphicon glyphicon-search"></span>
                </button>
            </form>

        </div>
        <table class="table table-bordered table-hover table-striped">
            <thead class="root">
            <tr>
                <th>序号</th>
                {% for item in header_list %}
                    <th style="text-align: center;">{{ item }}</th>
                {% endfor %}
            </tr>
            </thead>
            <tbody>
            {% for row in body_list %}
                <tr>
                    <td class="" style="vertical-align: middle;text-align: center;">{{ forloop.counter }}</td>
                    {% for ele in row %}
                        <td style="vertical-align: middle;text-align: center;">{{ ele }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}
            </tbody>
        </table>

        <ul class="pagination">
            {{ pager.html }}
        </ul>
        <div class="row">
            <div class="col-md-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <i class="fa fa-pie-chart" aria-hidden="true"></i> 站点请求分布(正常请求)
                    </div>
                    <div class="panel-body">
                        <div id="normalRquest" cid="{{ id }}" style="height: 300px;"></div>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <i class="fa fa-pie-chart" aria-hidden="true"></i> 站点请求分布(异常请求)
                    </div>
                    <div class="panel-body">
                        <div id="abnormalRquest" style="height: 300px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>


{% endblock %}

{% block js %}
    <script src="{% static 'plugins/highcharts/highcharts.js' %}"></script>
    <script src="{% static 'js/pie_chart.js' %}"></script>
    <script>
        var CHART_NORMAL_TITLE = "站点请求分布(正常请求）";
        var CHART_ABNORMAL_TITLE = "站点请求分布(异常请求）";
        var NORMAL_API_URL = "{% url 'botgate_normalrequest_chart' %}";
        var ABNORMAL_API_URL = "{% url 'botgate_abnormalrequest_chart' %}";
        var CID = $("#normalRquest").attr("cid");
        $(function () {
            initPieChart(NORMAL_API_URL, CHART_NORMAL_TITLE,CID,'normalRquest');
            initPieChart(ABNORMAL_API_URL, CHART_ABNORMAL_TITLE,CID,'abnormalRquest');
        });

    </script>
{% endblock %}